/*
* @File Name: collideCtl.c
* @File Path: K:\work\MAS2\PRM_robotic_arm\PRMCcode\coding\acc\collideCtl.c
* @Author: 29505
* @Date:   2019-07-23 19:14:38
* @Last Modified by:   29505
* @Last Modified time: 2019-07-23 21:39:27
* @Email: 295054118@whut.edu.cn
*/

#include <stdint.h>

__attribute__ ((section("dataBf1"))) volatile const uint32_t lookUpTrueTable[16384][256]= {0,1,2,3,4};
__attribute__ ((section("dataBf2"))) volatile uint32_t DestBuffer[256] = {0,0,0,0,0};
uint64_t* DestPLMemory = (uint64_t*)0x80000000;


uint32_t cl_reset()
{

	UINTPTR addr = 0;

	Xil_Out32(AXI_COLLIDECTL_BASE, 0x01);
	return 0;
}

uint32_t cl_set()
{

	UINTPTR addr = 0;

	Xil_Out32(AXI_COLLIDECTL_BASE, 0x00);
	return 0;
}


uint32_t cl_read( uint8_t regPart )
{
	UINTPTR addr = 0;

	addr = AXI_STEPPER_BASE + (regPart) * 4 ;

	return (Xil_In32(addr));
}


/*
	check grid from 0-16383
*/
uint32_t cl_check_grid( uint16_t gridNum )
{
	return XAxiCdma_SimpleTransfer(&AxiCdmaInstance, 
		(UINTPTR)lookUpTrueTable[gridNum], (UINTPTR)DestPLMemory, 
		BUFFER_BYTESIZE, NULL, NULL);
	
}


